package framework.service.impl;

import framework.bo.SysMenu;
import framework.dao.ISysMenuDao;
import framework.service.SysMenuService;
import framework.util.queryFilter.service.impl.IBaseServiceImpl;
import framework.util.queryFilter.service.impl.QueryFilter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author 吴宇亮 on 2019/2/7 0007 17:48
 */
@Service("SysMenuService")
public class SysMenuServiceImpl extends IBaseServiceImpl<SysMenu, Integer> implements SysMenuService {

    @Resource
    private ISysMenuDao dao;

    /**
     * 使用定时器每5个小时执行一次select 1，防止jdbc断开连接。因为mysql连接默认是8小时不用就会断开；oracle也是有个时间限制
     */
    public void select1ForKeepConnetionDatabase(){
        try {
            dao.select1ForKeepConnetionDatabase();
            System.out.println("select 1执行成功, 数据库保持连接");
        }catch (Exception e){
            log.error("", e);
        }
    };

    @Override
    public List<SysMenu> listTreeFilterByRole(Map<String, String> requestMap) {
        QueryFilter.autoFilterByRequestMap(requestMap);
        return dao.listTreeFilterByRole(requestMap);
    }

    @Override
    public List<SysMenu> list(Map<String, String> requestMap) {
        QueryFilter.autoFilterByRequestMap(requestMap);
        return dao.list(requestMap);
    }


}
